package com.twu.biblioteca;

import java.util.HashMap;

/**
 * Created by isabellali on 11/06/2014.
 * Movie Class
 */
public class Movie {
    private String name;
    private int year;
    private String director;
    private String rate;
    private boolean inLibrary;

    Movie(String name, int year, String director, String rate){
        this.name = name;
        this.year = year;
        this.director = director;
        this.rate = rate;
        this.inLibrary = true;
    }
    Movie(){
        this.name = null;
        this.year = 0;
        this.director = null;
        this.rate = null;
        this.inLibrary = true;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getYear() {
        return year;
    }

    public void setYear(int year) {
        this.year = year;
    }

    public String getDirector() {
        return director;
    }

    public void setDirector(String director) {
        this.director = director;
    }

    public String getRate() {
        return rate;
    }

    public void setRate(String rate) {
        this.rate = rate;
    }

    public boolean isInLibrary() {
        return inLibrary;
    }

    void setInLibrary(boolean inLibrary) {
        this.inLibrary = inLibrary;
    }


    public String checkOutMovie(Movie movie, HashMap<String, Movie> movieLibrary){
        if(movieLibrary.containsKey(movie.getName())) {
            Movie temp = movieLibrary.get(movie.getName());
            if(!temp.isInLibrary())
                return  "That movie is not available.";
            else{
                temp.setInLibrary(false);
                movieLibrary.put(movie.getName(),temp);
                return "Thank you! Enjoy the movie.";
            }
        }
        return "That movie is not available.";
    }
}
